package org.rency.ues.dal.repository.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.rency.ues.dal.dao.CertificationDao;
import org.rency.ues.dal.entity.CertificationDO;
import org.rency.ues.dal.repository.CertificationRepository;

public class CertificationRepositoryImpl implements CertificationRepository {

	private CertificationDao certificationDao;
	
	@Override
	public List<CertificationDO> loadAll() {
		return certificationDao.loadAll();
	}

	@Override
	public CertificationDO get(int id) {
		return certificationDao.get(id);
	}

	@Override
	public CertificationDO getBySerialNo(int serialNo) {
		return certificationDao.getBySerialNo(serialNo);
	}

	@Override
	public boolean save(CertificationDO entity) {
		return certificationDao.insert(entity) == 1;
	}

	@Override
	public boolean delete(int id) {
		return certificationDao.delete(id) == 1;
	}

	@Override
	public boolean updateVersion(int id, long newVersion, long oldVersion) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("id", id);
		param.put("newVersion", newVersion);
		param.put("oldVersion", oldVersion);
		return certificationDao.updateVersion(param) == 1;
	}

	
	public void setCertificationDao(CertificationDao certificationDao) {
		this.certificationDao = certificationDao;
	}

}